package com.gqj.elec.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gqj.common.annotation.Log;
import com.gqj.common.core.controller.BaseController;
import com.gqj.common.core.domain.AjaxResult;
import com.gqj.common.enums.BusinessType;
import com.gqj.elec.domain.ElecMaterialCheckdetails;
import com.gqj.elec.service.IElecMaterialCheckdetailsService;
import com.gqj.common.utils.poi.ExcelUtil;
import com.gqj.common.core.page.TableDataInfo;

/**
 * 资产盘点子Controller
 * 
 * @author lxq
 * @date 2023-12-17
 */
@RestController
@RequestMapping("/elec/elecMaterialCheckDetails")
public class ElecMaterialCheckdetailsController extends BaseController
{
    @Autowired
    private IElecMaterialCheckdetailsService elecMaterialCheckdetailsService;

    /**
     * 查询资产盘点子列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheckDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElecMaterialCheckdetails elecMaterialCheckdetails)
    {
        startPage();
        List<ElecMaterialCheckdetails> list = elecMaterialCheckdetailsService.selectElecMaterialCheckdetailsList(elecMaterialCheckdetails);
        return getDataTable(list);
    }

    /**
     * 导出资产盘点子列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheckDetails:export')")
    @Log(title = "资产盘点子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElecMaterialCheckdetails elecMaterialCheckdetails)
    {
        List<ElecMaterialCheckdetails> list = elecMaterialCheckdetailsService.selectElecMaterialCheckdetailsList(elecMaterialCheckdetails);
        ExcelUtil<ElecMaterialCheckdetails> util = new ExcelUtil<ElecMaterialCheckdetails>(ElecMaterialCheckdetails.class);
        util.exportExcel(response, list, "资产盘点子数据");
    }

    /**
     * 获取资产盘点子详细信息
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheckDetails:query')")
    @GetMapping(value = "/{checkDetailId}")
    public AjaxResult getInfo(@PathVariable("checkDetailId") Long checkDetailId)
    {
        return AjaxResult.success(elecMaterialCheckdetailsService.selectElecMaterialCheckdetailsByCheckDetailId(checkDetailId));
    }

    /**
     * 新增资产盘点子
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheckDetails:add')")
    @Log(title = "资产盘点子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElecMaterialCheckdetails elecMaterialCheckdetails)
    {
        return toAjax(elecMaterialCheckdetailsService.insertElecMaterialCheckdetails(elecMaterialCheckdetails));
    }

    /**
     * 修改资产盘点子
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheckDetails:edit')")
    @Log(title = "资产盘点子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElecMaterialCheckdetails elecMaterialCheckdetails)
    {
        return toAjax(elecMaterialCheckdetailsService.updateElecMaterialCheckdetails(elecMaterialCheckdetails));
    }

    /**
     * 删除资产盘点子
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialCheckDetails:remove')")
    @Log(title = "资产盘点子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkDetailIds}")
    public AjaxResult remove(@PathVariable Long[] checkDetailIds)
    {
        return toAjax(elecMaterialCheckdetailsService.deleteElecMaterialCheckdetailsByCheckDetailIds(checkDetailIds));
    }
}
